
<template>
  <div></div>
</template>
<script>
// 引入 echarts 核心模块，核心模块提供了 echarts 使用必须要的接口。
import * as echarts from "echarts";
export default {
  props: {},
  data() {
    return {
      arr: [],
    };
  },
  watch: {},
  created() {},
  mounted() {
    console.log(2);
    this.init();
  },
  methods: {
    init() {
      let myEhcart = echarts.init(document.querySelector(".bar-box"));
      let option = {
        title: {
          text: "堆叠区域图",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "10%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            maxInterval: 3600 * 24 * 1000,
            boundaryGap: false,
            data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
          },
        ],
        yAxis: [
          {
            type: "value",
            axisLabel: {
              formatter: (value, index) => {
                return (value / (3000 / 100)).toFixed(0) + "%";
              },
            },
          },
        ],
        series: [
          {
            name: "邮件营销",
            type: "line",
            stack: "总量",
            endLabel: {
              show: true,
            },
            areaStyle: {},
            symbol: "none", //拐点样式
            symbolSize: 0,
            lineStyle: {
              width: 0,
            },
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "联盟广告",
            type: "line",
            stack: "总量",
            areaStyle: {},
            symbol: "none", //拐点样式
            lineStyle: {
              width: 0,
            },
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "视频广告",
            type: "line",
            stack: "总量",
            symbol: "none", //拐点样式
            areaStyle: {},
            lineStyle: {
              width: 0,
            },
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "直接访问",
            type: "line",
            stack: "总量",
            areaStyle: {
              // color:"red"
            },
            symbol: "none", //拐点样式
            lineStyle: {
              width: 0,
            },
            data: [320, 100, 330, 302, 390, 330, 320],
          },
          {
            name: "搜索引擎",
            type: "line",
            stack: "总量",
            symbol: "none", //拐点样式
            lineStyle: {
              width: 0,
            },
            areaStyle: {
              opacity: 0.5,
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "red", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "blue", // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
            data: [2000, 1330, 1330, 1330, 1330, 1330, 1330],
          },
        ],
      };
      myEhcart.setOption(option);
      // 设置图表的自动适应
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    },
  },
};
</script>
<style scoped lang='scss'>
</style>